//
//  SSHTTPClient.swift
//  weibo
//
//  Created by 邵帅 on 16/6/24.
//  Copyright © 2016年 groupNineObject. All rights reserved.
//

import UIKit
import AFNetworking

enum ClientType : String{
    case POST = "POST"
    case GET = "GET"
}

class SSHTTPClient: AFHTTPSessionManager {
    
    // 单例
    static let shareInstance : SSHTTPClient = {
        
        let client = SSHTTPClient()
        
        client.responseSerializer.acceptableContentTypes?.insert("text/plain")
        
        return client
    }()


    
    // 请求
    func request(type : ClientType, URLString: String, parameters: AnyObject?, progress downloadProgress: ((NSProgress) -> Void)?, success: ((NSURLSessionDataTask, AnyObject?) -> Void)?, failure: ((NSURLSessionDataTask?, NSError) -> Void)?) {
        
        if type == .GET {
            
            self.GET(URLString, parameters: parameters, progress: nil, success: success, failure: failure)
        
        }else if type == .POST{
            
            self.POST(URLString, parameters: parameters, progress: nil, success: success, failure: failure)
        }
        
        
    }
}
